<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../img/asset-favico.ico">
    <title>爱健康</title>
    <link rel="stylesheet" href="../css/page-health-index.css" />
    <link rel="stylesheet" href="../css/page-health-login.css" />
    <link rel="stylesheet" href="../plugins/elementui/index.css" />
    <script src="../plugins/jquery/dist/jquery.min.js"></script>
    <script src="../plugins/healthmobile.js"></script>
    <script src="../plugins/vue/vue.js"></script>
    <script src="../plugins/vue/axios-0.18.0.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <style>
        .image-viewer {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.8);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }
        .image-viewer img {
            max-width: 90%;
            max-height: 90%;
            cursor: pointer;
        }
        .close-button {
            position: absolute;
            top: 20px;
            right: 30px;
            color: white;
            font-size: 24px;
            cursor: pointer;
        }
    </style>
</head>
<body data-spy="scroll" data-target="#myNavbar" data-offset="150">
    <div class="app">
        <!-- 页面头部 -->
        <div class="top-header">
            <span class="f-left"><i class="icon-back" onclick="history.go(-1)"></i></span>
            <span class="center">爱健康</span>
            <span class="f-right"><i class="icon-more"></i></span>
        </div>
        <!-- 页面内容 -->
        <div class="contentBox">
            <div class="list-column2">
                <ul class="list">
                    <li class="type-item" style="width: 100%" v-for="record in records" >
                        <a class="link-page" @click="fetchRecordDetails(record.id)">
                            <div class="type-title">
                                <h3>{{ record.name }}</h3>
                                <p>会员编号: {{ record.fileNumber }}</p>
                                <p>联系电话: {{ record.phoneNumber }}</p>
                                <p>上传时间: {{ record.upLoadTime }}</p>
                            </div>
                            <div class="type-icon">
                                查看
                            </div>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
        <!-- 图片查看器 -->
        <div class="image-viewer" v-if="showImageViewer" @click="closeImageViewer">
            <span class="close-button" @click="closeImageViewer">&times;</span>
            <img :src="imageSrc" alt="体检图片" @click.stop>
        </div>
    </div>
</body>
<script>
    var vue = new Vue({
        el: '.app',
        data: {
            records: [],
            showImageViewer: false,
            imageSrc: ''
        },
        created(){
            this.viewReport();
        },
        methods: {
            viewReport() {
                axios.get(`/userExamination/report.do`).then((res) => {
                    if (res.data.flag) {
                        this.records = res.data.data; // 更新 records 数据
                    } else {
                        if (res.data.message === '未登录') {
                            window.location.href = "../login.html";
                        } else {
                            this.$message.error(res.data.message);
                        }
                    }
                });
            },
            fetchRecordDetails(id) {
                axios.get(`/userExamination/findById/${id}.do`).then((res) => {
                    if (res.data.flag) {
                        this.imageSrc = "http://mhr-health.oss-cn-beijing.aliyuncs.com/" + res.data.data.examinationImg; // 修改为返回的图片URL在data字段中
                        this.showImageViewer = true;
                    } else {
                        this.$message.error(res.data.message);
                    }
                });
            },
            closeImageViewer() {
                this.showImageViewer = false;
            }
        }
    });
</script>
</html>